package com.crm.crm.controller;


import com.crm.crm.domain.Dept;
import com.crm.crm.domain.vo.business.result.Result;
import com.crm.crm.domain.vo.business.DeptNode;
import com.crm.crm.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Slf4j
@RestController
@RequestMapping("/system/dept")
public class DeptController {
    @Autowired
    private DeptService deptService;
    /**
     * 获取部门树用于 treeselect 组件，
     * 这是商机模块的分配所属人时候调用的接口
     */
    @GetMapping("/treeselect")
    public Object getDeptTree() {
        log.info("获取部门树");
        List<DeptNode> deptTree = deptService.getDeptTree();
        log.info("部门树：{}", deptTree);
        return Result.success(deptTree);
    }
    @GetMapping("/list")
    public Result getDeptList() {
        List<Dept> deptTree = deptService.getDeptList();
        return Result.success(deptTree);
    }
}
